#include "free_sw_spi.h"

#include "main.h"
void hal_set_sclk(bool level)
{
    HAL_GPIO_WritePin(SPI_SCLK_GPIO_Port, SPI_SCLK_Pin, level);
}

void hal_set_mosi(bool level)
{
    HAL_GPIO_WritePin(SPI_MOSI_GPIO_Port, SPI_MOSI_Pin, level);
}

bool hal_get_miso(void)
{
    return HAL_GPIO_ReadPin(SPI_MISO_GPIO_Port, SPI_MISO_Pin);
}
void hal_delay(void)
{
    _IO uint32_t t = 72;
    while (t)
    {
        t--;
    }
}

Swspi sw_spi;

void sw_encoder_examples(void)
{
    int count = 0;

    sw_spi_init(&sw_spi, hal_set_sclk, hal_set_mosi, hal_get_miso, hal_delay, 0);

    while (1)
    {
        uint8_t data[256];
        sw_spi_transmit(&sw_spi, data, 256);
    }
}
